﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:l="http://wpflocalizeextension.codeplex.com"
    xmlns:Common.Data.Converters="clr-namespace:Imagin.Common.Data.Converters;assembly=Imagin.Common"
    xmlns:Common.Extensions="clr-namespace:Imagin.Common.Extensions;assembly=Imagin.Common"
    xmlns:Controls.Common="clr-namespace:Imagin.Controls.Common;assembly=Imagin.Controls.Common">
    <Style x:Key="{x:Type Menu}" TargetType="{x:Type Menu}">
        <Setter Property="Background" Value="{DynamicResource Brush.Menu.Background}" />
        <Setter Property="Foreground" Value="{DynamicResource Brush.Menu.Foreground}" />
    </Style>

    <Style x:Key="{x:Type MenuItem}" TargetType="{x:Type MenuItem}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Background" Value="{DynamicResource Brush.MenuItem.Background}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource Brush.MenuItem.Border}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Foreground" Value="{DynamicResource Brush.MenuItem.Foreground}"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="Margin" Value="0"/>
        <Setter Property="MaxHeight" Value="720" />
        <Setter Property="Padding" Value="0,3"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type MenuItem}">
                    <Border 
                        x:Name="PART_Border" 
                        Background="{TemplateBinding Background}" 
                        BorderBrush="{TemplateBinding BorderBrush}" 
                        BorderThickness="{TemplateBinding BorderThickness}" 
                        Margin="{TemplateBinding Margin}"
                        SnapsToDevicePixels="False">
                        <Grid x:Name="PART_Grid">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition x:Name="Col0" MinWidth="50" Width="Auto" SharedSizeGroup="MenuItemIconColumnGroup" />
                                <ColumnDefinition Width="Auto" SharedSizeGroup="MenuTextColumnGroup" />
                                <ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup" />
                                <ColumnDefinition x:Name="Col3" Width="14" />
                            </Grid.ColumnDefinitions>
                            <Grid>
                                <Controls.Common:MaskedImage 
                                    x:Name="PART_Bullet" 
                                    HorizontalAlignment="Stretch"  
                                    HorizontalContentAlignment="Center"
                                    ImageColor="{TemplateBinding Foreground}"
                                    ImageWidth="8"
                                    Source="pack://application:,,,/Imagin.Styles;component/Images/Dot.png" 
                                    VerticalAlignment="Stretch"
                                    Visibility="Collapsed"/>
                                <Controls.Common:MaskedImage 
                                    x:Name="PART_Icon" 
                                    HorizontalAlignment="Center"  
                                    ImageColor="{TemplateBinding Foreground}"
                                    Source="{Binding Icon, RelativeSource={RelativeSource TemplatedParent}}"
                                    VerticalAlignment="Center"/>
                            </Grid>

                            <ContentPresenter 
                                Grid.Column="1" 
                                x:Name="PART_Header" 
                                ContentSource="Header" 
                                TextBlock.Foreground="{TemplateBinding Foreground}"
                                Margin="{TemplateBinding Padding}" 
                                RecognizesAccessKey="True" 
                                VerticalAlignment="Center"/>
                            <ContentPresenter 
                                Grid.Column="2" 
                                x:Name="PART_InputGesture" 
                                Margin="8,0" 
                                ContentSource="InputGestureText" 
                                VerticalAlignment="Center"/>
                            <Grid 
                                Grid.Column="3" 
                                x:Name="PART_Arrow" 
                                Margin="4,0,6,0" 
                                VerticalAlignment="Center">
                                <Path 
                                    x:Name="PART_ArrowPath" 
                                    HorizontalAlignment="Right" 
                                    VerticalAlignment="Center" 
                                    Fill="{TemplateBinding Foreground}" 
                                    Data="M0,0 L0,8 L4,4 z" />
                            </Grid>
                            <Popup 
                                x:Name="PART_Submenu" 
                                AllowsTransparency="True"
                                Focusable="false" 
                                HorizontalOffset="-1" 
                                IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" 
                                Placement="Right" 
                                PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}" >
                                <Border 
                                    x:Name="PART_SubmenuBorder" 
                                    Background="{DynamicResource Brush.MenuItem.Popup.Background}" 
                                    BorderBrush="{DynamicResource Brush.MenuItem.Popup.Border}" 
                                    BorderThickness="1" 
                                    SnapsToDevicePixels="True">
                                    <Border.Effect>
                                        <DropShadowEffect Color="{DynamicResource DropShadowColor}" Opacity="0.25" BlurRadius="8" ShadowDepth="5"/>
                                    </Border.Effect>
                                    <ScrollViewer
                                        Grid.IsSharedSizeScope="True"
                                        x:Name="SubMenu" >
                                        <StackPanel 
                                            IsItemsHost="True" 
                                            KeyboardNavigation.DirectionalNavigation="Cycle"
                                            MaxHeight="{TemplateBinding MaxHeight}"/>
                                    </ScrollViewer>
                                </Border>
                            </Popup>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Role" Value="TopLevelHeader">
                            <Setter TargetName="Col0" Property="MinWidth" Value="0" />
                            <Setter TargetName="Col3" Property="Width" Value="Auto" />
                            <Setter TargetName="PART_Arrow" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="PART_Icon" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="PART_InputGesture" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="PART_Submenu" Property="Placement" Value="Bottom" />
                            <Setter TargetName="PART_SubmenuBorder" Property="BorderThickness" Value="1" />
                        </Trigger>
                        <Trigger Property="Role" Value="TopLevelItem">
                            <Setter TargetName="Col0" Property="MinWidth" Value="0" />
                            <Setter TargetName="Col3" Property="Width" Value="Auto" />
                            <Setter TargetName="PART_Arrow" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="PART_Icon" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="PART_InputGesture" Property="Visibility" Value="Collapsed" />
                            <Setter Property="Padding" Value="10,2" />
                        </Trigger>
                        <Trigger Property="Role" Value="SubmenuHeader">
                            <Setter TargetName="PART_Border" Property="MinHeight" Value="22" />
                            <Setter TargetName="PART_Bullet" Property="Margin" Value="0,0,5,0" />
                            <Setter TargetName="PART_Icon" Property="Margin" Value="0,0,5,0" />
                            <Setter Property="Padding" Value="0,6" />
                            <Setter Property="DockPanel.Dock" Value="Top" />
                        </Trigger>
                        <Trigger Property="Role" Value="SubmenuItem">
                            <Setter TargetName="PART_Arrow" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="PART_Border" Property="MinHeight" Value="22" />
                            <Setter TargetName="PART_Bullet" Property="Margin" Value="0,0,5,0" />
                            <Setter TargetName="PART_Icon" Property="Margin" Value="0,0,5,0" />
                            <Setter Property="DockPanel.Dock" Value="Top" />
                            <Setter Property="Padding" Value="0,6" />
                        </Trigger>
                        <Trigger Property="IsSuspendingPopupAnimation" Value="true">
                            <Setter TargetName="PART_Submenu" Property="PopupAnimation" Value="None" />
                        </Trigger>
                        <Trigger Property="Icon" Value="{x:Null}">
                            <Setter TargetName="PART_Icon" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="PART_Header" Property="Opacity" Value="0.6"/>
                            <Setter TargetName="PART_InputGesture" Property="Opacity" Value="0.6"/>
                        </Trigger>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="PART_Bullet" Property="Visibility" Value="Visible" />
                            <Setter TargetName="PART_Bullet" Property="Background" Value="{DynamicResource Brush.MenuItem.Checked.Bullet.Background}" />
                            <Setter TargetName="PART_Bullet" Property="Margin" Value="0,0,7,0" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsHighlighted" Value="True" />
                                <Condition Property="IsChecked" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="PART_Bullet" Property="Background" Value="{DynamicResource Brush.MenuItem.Checked.MouseOver.Bullet.Background}" />
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Role" Value="TopLevelHeader">
                <Setter Property="Padding" Value="10,2" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsHighlighted" Value="True" />
                    <Condition Property="Role" Value="TopLevelHeader" />
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="{DynamicResource Brush.MenuItem.TopLevelHeader.MouseOver.Background}" />
                <Setter Property="BorderBrush" Value="{DynamicResource Brush.MenuItem.TopLevelHeader.MouseOver.Border}" />
                <Setter Property="Foreground" Value="{DynamicResource Brush.MenuItem.TopLevelHeader.MouseOver.Foreground}" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsSubmenuOpen" Value="True" />
                    <Condition Property="Role" Value="TopLevelHeader" />
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="{DynamicResource Brush.MenuItem.TopLevelHeader.Pressed.Background}" />
                <Setter Property="BorderBrush" Value="{DynamicResource Brush.MenuItem.TopLevelHeader.Pressed.Border}" />
                <Setter Property="Foreground" Value="{DynamicResource Brush.MenuItem.TopLevelHeader.Pressed.Foreground}" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsHighlighted" Value="True" />
                    <Condition Property="Role" Value="SubmenuHeader" />
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="{DynamicResource Brush.MenuItem.SubmenuHeader.MouseOver.Background}" />
                <Setter Property="BorderBrush" Value="{DynamicResource Brush.MenuItem.SubmenuHeader.MouseOver.Border}" />
                <Setter Property="Foreground" Value="{DynamicResource Brush.MenuItem.SubmenuHeader.MouseOver.Foreground}" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsHighlighted" Value="False" />
                    <Condition Property="Role" Value="SubmenuHeader" />
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="{DynamicResource Brush.MenuItem.SubmenuHeader.Background}" />
                <Setter Property="BorderBrush" Value="{DynamicResource Brush.MenuItem.SubmenuHeader.Border}" />
                <Setter Property="Foreground" Value="{DynamicResource Brush.MenuItem.SubmenuHeader.Foreground}" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsHighlighted" Value="True" />
                    <Condition Property="Role" Value="SubmenuItem" />
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="{DynamicResource Brush.MenuItem.SubmenuItem.MouseOver.Background}" />
                <Setter Property="BorderBrush" Value="{DynamicResource Brush.MenuItem.SubmenuItem.MouseOver.Border}" />
                <Setter Property="Foreground" Value="{DynamicResource Brush.MenuItem.SubmenuItem.MouseOver.Foreground}" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsHighlighted" Value="False" />
                    <Condition Property="Role" Value="SubmenuItem" />
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="{DynamicResource Brush.MenuItem.SubmenuItem.Background}" />
                <Setter Property="BorderBrush" Value="{DynamicResource Brush.MenuItem.SubmenuItem.Border}" />
                <Setter Property="Foreground" Value="{DynamicResource Brush.MenuItem.SubmenuItem.Foreground}" />
            </MultiTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}">
        <Setter Property="BorderBrush" Value="{DynamicResource Brush.Line.Stroke}" />
        <Setter Property="Height" Value="1" />
        <Setter Property="Margin" Value="10,3" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Separator}">
                    <Border 
                        BorderBrush="{TemplateBinding BorderBrush}" 
                        BorderThickness="0,1,0,0" 
                        Margin="0" 
                        CornerRadius="0" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="Style.MenuItem.Empty" TargetType="{x:Type MenuItem}" BasedOn="{StaticResource {x:Type MenuItem}}">
        <Setter Property="Header" Value="{l:LocText none, Prefix=(, Suffix=)}"/>
        <Setter Property="IsEnabled" Value="False"/>
    </Style>
</ResourceDictionary>